<?php
/**
 * Created by PhpStorm.
 * User: dapeng
 * Date: 2018/10/17
 * Time: 上午10:45
 */

namespace app\controllers\Project_1_0;

use Core\Controller;

class Cases extends Controller
{
    function __construct()
    {
        parent::__construct();
        //判断是否登陆过
        if (!isset($_SESSION['user'])){
            $this->error("您尚未登录","index.php?action=user&func=login");
            exit();
        }
    }

    function index(){
        $model =  new \app\models\Project_1_0\Cases();
        $res = $model->fetch_all();
        //注意该方法是经过二次封装的
        $this->assign("cases",$res);
        $this->diplay("case/index");
    }

    function search(){
        //获取页面传过来的查询条件
        $option = $_POST['option'];

        $content = $_POST['content'];
        $cases = new \app\models\Project_1_0\Cases();
        $res = $cases->search($option,$content);
        $this->assign("cases",$res);
        $this->diplay("case/index");

    }

    //修改
    function finish()
    {
        $id=$_GET['id'];
        $cases = new \app\models\Project_1_0\Cases();
        $cases->edit($id);
        $res=$cases->fetch_all();
        $this->assign("cases",$res);
        $this->diplay("case/index");
    }

}